package locpris.swan.ac.uk;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;

import com.jme.math.Vector3f;

import locpris.swan.ac.uk.*;

//Module to collect data from URL/File

public class DataCollection implements Runnable{

	//Array List of Mobile Nodes
	private static ArrayList<MobileNode> mobileNodeList = new ArrayList<MobileNode>();
	//Array List of Access Points
	private static ArrayList<AccessPoint> accessPointList = new ArrayList<AccessPoint>();
	//total number of movements
	private int numberOfMovements=0;
	//Upper boundary of weight limit in self map
	private int upperBound = 200;
	//index of the previous ap seen
	private int previousAPIndex = 0;
	//theta value static
	private double theta = Math.random() * Math.PI * 2;
	//curent ap
	private AccessPoint currentAP = null;
	//previous AP
	private AccessPoint previousAP = null;
	//proxied set if new ap near existing ap
	private boolean proxied = false;

	
	public void DataCollection()
	{
		//nothing yet
	}
	
	public void run()
	{
		try {
			//dcm.getAllAPs();
			//dcm.getBuildingAPs("cfn");
			//dcm.getBuildingHour();
			//dcm.getaClient();
			//dcm.getaClient("40:5f:be:13:81:9");
			//ANode aNode = new ANode(new Vector3f(-4.0f,-2.0f,1.0f));
			//LocPriSMain.addNode(aNode.getNode());
			buildSelfMap("40:5f:be:13:81:9");
			//dcm.getHour();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void getHour() throws IOException
	{
		URL locaware = new URL("http://locaware.swan.ac.uk/dump_hour_to_locprivs.php");
		BufferedReader in = new BufferedReader(new InputStreamReader(locaware.openStream()));
		String line;
		String building;
		String client;
		String time;
		int comma=0;
		int comma2=0;
		
		while ((line = in.readLine()) != null)
		{ 
			//System.out.println(inputLine);
			comma = line.indexOf(',');
			building = line.substring(0, comma);
			comma2 = line.indexOf(',', comma+1);
			client = line.substring(comma+1,comma2);
			time = line.substring(comma2+1, line.length());
			System.out.println("Building="+building+" Client="+client+" Time="+time);
			//do come building to location stuff here
			//check if node already exists in list
			//if not make it
			if (checkNode(client)==1) {
				//node already in list
				System.out.println("Node already exists");
				//add location to node
				int buildrad=getBuildingSize(building);
				double theta = Math.random() * Math.PI * 2;
				double randx = Math.cos(theta) * Math.random() * buildrad;
				double randy = Math.sin(theta) * Math.random() * buildrad;
				MobileNode temp = getNode(client);
				Vector3f loc = getBuildingLocStatic(building);
				loc = loc.add((float)randx,0,(float)randy);
				temp.addNodeLocation(loc);
			}
			else
			{
				System.out.println("New Node");
				Vector3f loc = getBuildingLocStatic(building);
				//temp.addNodeLocation(loc);
				MobileNode temp = new MobileNode(client,loc);
				addNode(temp);
			}
		}

		in.close();
	 }
	
	public void getAllAPs() throws IOException
	{
		URL locaware = new URL("http://locaware.swan.ac.uk/LocPriS/dump_ap_to_locprivs.php");
		BufferedReader in = new BufferedReader(new InputStreamReader(locaware.openStream()));
		String line;
		String building;
		String client;
		String time;
		int comma=0;
		int comma2=0;
		System.out.println("Budiling AP List");
		while ((line = in.readLine()) != null)
		{ 
			//System.out.println(inputLine);
			building = line;
			System.out.println("AP Building="+building);
			//build access point list
			if (checkAP(building)==1) {
				//ap already in list
				System.out.println("AP already exists");
				//nothing to do...
				}
			else
			{
				Vector3f loc = getBuildingLocStatic(building);
				//temp.addNodeLocation(loc);
				int buildingrad = getBuildingSize(building);
				System.out.println("New AP ["+building+"] at "+loc.x +","+loc.z+ "with rad="+buildingrad);
				AccessPoint temp = new AccessPoint(loc,buildingrad,building,"2d",false);
				addAP(temp);
			}
		}

		in.close();
	}
	
	public void getBuildingAPs(String buildingname) throws IOException
	{
		URL locaware = new URL("http://locaware.swan.ac.uk/dump_building_hour.php?building="+buildingname);
		BufferedReader in = new BufferedReader(new InputStreamReader(locaware.openStream()));
		String line;
		String building;
		String client;
		String floor;
		String position;
		String time;
		String origAP;
		int fdash=0;
		int sdash=0;
		int tdash=0;
		int comma=0;
		int comma2=0;
		System.out.println("Budiling AP List");
		while ((line = in.readLine()) != null)
		{ 
			//System.out.println(inputLine);
			origAP=line;
			comma = line.indexOf(',');
			building = line.substring(0, comma);
			//exclude the odd ground ap for now
			if (building.equals("cfn-aironet-gnd")) { }
			else {
			fdash = building.indexOf('-');
			sdash = building.indexOf('-',fdash+1);
			tdash = building.indexOf('-',sdash+1);
			floor = building.substring(sdash+1,sdash+2);
			position = building.substring(tdash+1,tdash+2);
			System.out.println("AP="+building+" floor="+floor+" position="+position);
			if (checkAP(origAP)==1) {
				//ap already in list
				System.out.println("AP already exists");
				//nothing to do...
				}
			else
			{
				Vector3f loc = getAPLoc(building,floor,position);
				//temp.addNodeLocation(loc);
				int rad = 10;
				System.out.println("New AP ["+building+"] position="+floor+","+position+" at "+loc.x +","+loc.y+","+loc.z+ "with rad="+rad);
				AccessPoint temp = new AccessPoint(loc,rad,building,"3d",false);
				addAP(temp);
			}
		}
		}
		in.close();
	}
	
	public void getBuildingHour() throws IOException
	{
		URL locaware = new URL("http://locaware.swan.ac.uk/dump_building_hour.php?building=cfn");
		BufferedReader in = new BufferedReader(new InputStreamReader(locaware.openStream()));
		String line;
		String ap;
		String floor;
		String position;
		String client;
		String time;
		int fdash=0;
		int sdash=0;
		int tdash=0;
		int comma=0;
		int comma2=0;
		
		while ((line = in.readLine()) != null)
		{ 
			//System.out.println(inputLine);
			comma = line.indexOf(',');
			ap = line.substring(0, comma);
			//exclude the odd ground ap for now
			if (ap.equals("cfn-aironet-gnd")) { }
			else {
			fdash = ap.indexOf('-');
			sdash = ap.indexOf('-',fdash+1);
			tdash = ap.indexOf('-',sdash+1);
			floor = ap.substring(sdash+1,sdash+2);
			position = ap.substring(tdash+1,tdash+2);
			comma2 = line.indexOf(',', comma+1);
			client = line.substring(comma+1,comma2);
			time = line.substring(comma2+1, line.length());
			System.out.println("ap="+ap+" floor="+floor+" position="+position+" Client="+client+" Time="+time);
			//do come building to location stuff here
			//check if node already exists in list
			//if not make it
			if (checkNode(client)==1) {
				//node already in list
				System.out.println("Node already exists");
				//add location to node
				int rad=10;
				double theta = Math.random() * Math.PI * 2;
				double randx = Math.cos(theta) * Math.random() * rad;
				double randy = Math.sin(theta) * Math.random() * rad;
				MobileNode temp = getNode(client);
				Vector3f loc = getAPLoc(ap,floor,position);
				loc = loc.add((float)randx,0,(float)randy);
				temp.addNodeLocation(loc);
			}
			else
			{
				System.out.println("New Node");
				Vector3f loc = getAPLoc(ap,floor,position);
				//temp.addNodeLocation(loc);
				MobileNode temp = new MobileNode(client,loc);
				addNode(temp);
			}
		}
		}

		in.close();
	 }
	
	public void getaClient(String mac) throws IOException
	{
		URL locaware = new URL("http://locaware.swan.ac.uk/LocPriS/dump_client_to_locprivs.php?mac="+mac);
		BufferedReader in = new BufferedReader(new InputStreamReader(locaware.openStream()));
		String line;
		String building;
		String client;
		String time;
		int comma=0;
		int comma2=0;
		
		while ((line = in.readLine()) != null)
		{ 
			//System.out.println(inputLine);
			comma = line.indexOf(',');
			building = line.substring(0, comma);
			comma2 = line.indexOf(',', comma+1);
			client = line.substring(comma+1,comma2);
			time = line.substring(comma2+1, line.length());
			System.out.println("Building="+building+" Client="+client+" Time="+time);
			//BUILDING
			//build access point list
			if (checkAP(building)==1) {
				//ap already in list
				System.out.println("AP already exists");
				//nothing to do...
				}
			else
			{
				Vector3f loc = getBuildingLocStatic(building);
				//temp.addNodeLocation(loc);
				int buildingrad = getBuildingSize(building);
				System.out.println("New AP ["+building+"] at "+loc.x +","+loc.z+ "with rad="+buildingrad);
				AccessPoint temp = new AccessPoint(loc,buildingrad,building,"2d",false);
				addAP(temp);
			}
			
			//NODE
			
			//do come building to location stuff here
			//check if node already exists in list
			//if not make it
			if (checkNode(client)==1) {
				//node already in list
				System.out.println("Node already exists");
				//add location to node
				int buildrad=getBuildingSize(building);
				double theta = Math.random() * Math.PI * 2;
				double randx = Math.cos(theta) * Math.random() * buildrad;
				double randy = Math.sin(theta) * Math.random() * buildrad;
				MobileNode temp = getNode(client);
				Vector3f loc = getBuildingLocStatic(building);
				//loc = loc.add((float)randx,0,(float)randy);
				temp.addNodeLocation(loc);
			}
			else
			{
				System.out.println("New Node");
				Vector3f loc = getBuildingLocStatic(building);
				//temp.addNodeLocation(loc);
				MobileNode temp = new MobileNode(client,loc);
				addNode(temp);
			}
		}

		in.close();
	 }
	
	public void buildSelfMap(String mac) throws IOException
	{
		URL locaware = new URL("http://locaware.swan.ac.uk/LocPriS/dump_client_weights.php?mac="+mac);
		BufferedReader in = new BufferedReader(new InputStreamReader(locaware.openStream()));
		String line;
		String building;
		String client;
		String time;
		long stamp=0;
		int weight=0;
		int comma=0;
		int comma2=0;
		int comma3=0;
		int comma4=0;
		while ((line = in.readLine()) != null)
		{ 
			System.out.println("*****************************************got a line");
			comma = line.indexOf(',');
			comma2 = line.indexOf(',', comma+1);
			comma3 = line.indexOf(',', comma2+1);
			comma4 = line.indexOf(',', comma3+1);
			building = line.substring(0, comma);
			client = line.substring(comma+1,comma2);
			time = line.substring(comma2+1, comma3);
			stamp = new Long(line.substring(comma3+1, comma4));
			weight = new Integer(line.substring(comma4+1, line.length()));
			proxied=false;
			
			System.out.println("Building="+building+" Client="+client+" Time="+time+" Stamp="+stamp+" Weight="+weight);
			
			//set weight to be relative to meters in map
			//weight = Math.round(weight / ( upperBound / 10) );
			//System.out.println("Relative weight="+weight);
			
			//get previous node from ap list
			if (accessPointList.size()>0) previousAP = accessPointList.get(previousAPIndex);
			else	previousAP=null;
			//System.out.println("pre index="+previousAPIndex);
			//BUILDING*************************************************************************************************
			//build access point list
			boolean newnode=false;
			if (checkAP(building)==1) {
				//******AP ALREADY EXISTS, so set to currentAP
				System.out.println("AP already exists");
				newnode=false;
				}
			else
			{
				//******NEW AP
				Vector3f loc = getBuildingStartLoc(building,previousAP,weight);
				//int buildingrad = getBuildingSize(building);
				int buildingrad = 10;
				System.out.println("New AP ["+building+"] at "+loc.x +","+loc.z+ "with rad="+buildingrad);
				AccessPoint temp = new AccessPoint(loc,buildingrad,building,"2d",proxied);
				currentAP = temp;
				addAP(temp);
				newnode=true;
			}
			
			//NEIGHBOUR CHECK**********************************************************
			if (previousAP==null || weight > upperBound || building.equals(previousAP.getName()))
			{
				//not neighbours
				if (previousAP==null) System.out.println(currentAP.getName()+" has NO neighbours");
				else { System.out.println(currentAP.getName()+" and "+previousAP.getName()+" are NOT neighbours");}
			}
			else
			{
				System.out.println(currentAP.getName()+" and "+previousAP.getName()+" ARE neighbours");
				//neighbours
				boolean better = false;
				better=currentAP.setNeighbour(previousAP.getName(), weight, previousAP.getLocation(previousAP.getNumberOfNodes()-1));
				better=previousAP.setNeighbour(currentAP.getName(), weight,currentAP.getLocation(currentAP.getNumberOfNodes()-1));
				System.out.println("currap="+currentAP.getName()+" prevap="+previousAP.getName());
				//check if already neighbours, but not if new node
				if (better==true && newnode==false)
				{
					//check it has no attached neighbours except currentAP
					if (previousAP.getNumberNeighbours()<2)
					{
						//move previuosAP near currentAP within weight
						Vector3f loc = adjustAP(weight);
						//sleep?
						previousAP.changeLocation(loc,proxied);
					}
					else
					{
						//additional neighbours to consider and move?
						//get all neighbours and if upper bound < weight, move them.
						
					}
				}	
				else
				{
					//new node, but may still have a neighbour link
					if (proxied)
					{
						//reposition to its current location, but establish links to neighbours
						Vector3f loc = currentAP.getLocation(currentAP.getNumberOfNodes()-1);
						currentAP.changeLocation(loc,proxied);
					}
				}
				
			}
			
			//NODE****************************************************************************************************
			
			//do come building to location stuff here
			//check if node already exists in list
			//if not make it
//			if (checkNode(client)==1) {
//				//node already in list
//				System.out.println("Node already exists, possible new location");
//				//add location to node
//				int buildrad=10;
//				double theta = Math.random() * Math.PI * 2;
//				double randx = Math.cos(theta) * Math.random() * buildrad;
//				double randy = Math.sin(theta) * Math.random() * buildrad;
//				MobileNode temp = getNode(client);
//				Vector3f loc = getBuildingLoc(building);
//				numberOfMovements++;
//				//comment/uncomment below for random pos in rad
//				loc = loc.add((float)randx,0,(float)randy);
//				temp.addNodeLocation(loc);
//			}
//			else
//			{
//				System.out.println("New Node");
//				Vector3f loc = getBuildingLoc(building);
//				//temp.addNodeLocation(loc);
//				MobileNode temp = new MobileNode(client,loc);
//				addNode(temp);
//			}
			
			//***************************************************
			//sleeps for one second to give impression of movement
			try {
				Thread.sleep(1000);
			}
			catch (InterruptedException e)
			{
				System.out.println("e="+e);
			}
		}

		in.close();
		dumpData();
	 }

	
	public void getaClient() throws IOException
	{
		URL locaware = new URL("http://locaware.swan.ac.uk/dump_client_to_locprivs.php");
		BufferedReader in = new BufferedReader(new InputStreamReader(locaware.openStream()));
		String line;
		String building;
		String client;
		String time;
		int comma=0;
		int comma2=0;
		
		while ((line = in.readLine()) != null)
		{ 
			//System.out.println(inputLine);
			comma = line.indexOf(',');
			building = line.substring(0, comma);
			comma2 = line.indexOf(',', comma+1);
			client = line.substring(comma+1,comma2);
			time = line.substring(comma2+1, line.length());
			System.out.println("Building="+building+" Client="+client+" Time="+time);
			//do come building to location stuff here
			//check if node already exists in list
			//if not make it
			if (checkNode(client)==1) {
				//node already in list
				System.out.println("Node already exists");
				//add location to node
				int buildrad=getBuildingSize(building);
				double theta = Math.random() * Math.PI * 2;
				double randx = Math.cos(theta) * Math.random() * buildrad;
				double randy = Math.sin(theta) * Math.random() * buildrad;
				MobileNode temp = getNode(client);
				Vector3f loc = getBuildingLocStatic(building);
				loc = loc.add((float)randx,0,(float)randy);
				temp.addNodeLocation(loc);
			}
			else
			{
				System.out.println("New Node");
				Vector3f loc = getBuildingLocStatic(building);
				//temp.addNodeLocation(loc);
				MobileNode temp = new MobileNode(client,loc);
				addNode(temp);
			}
		}

		in.close();
	 }
	
	public void addNode(MobileNode anode)
	{
		mobileNodeList.add(anode);
	}
	
	public void addAP(AccessPoint aAP)
	{
		accessPointList.add(aAP);
	}
	
	public int checkNode(String name)
	{
		MobileNode temp;
		int found = 0;
		int len = mobileNodeList.size();
		for (int n =0; n < len; n++)
		{
			temp = mobileNodeList.get(n);
			if (temp.getName().equals(name)) { found=1;}
		}
		return found;
	}
	
	public int getNumberAPs()
	{
		return accessPointList.size();
	}
	
	public int getNumberNodes()
	{
		return mobileNodeList.size();
	}
	
	public int getNumberMovements()
	{
		return numberOfMovements;
	}
	
	public int checkAP(String name)
	{
		AccessPoint temp;
		int found = 0;
		int len = accessPointList.size();
		for (int n =0; n < len; n++)
		{
			temp = accessPointList.get(n);
			if (temp.getName().equals(name)) { found=1; previousAPIndex=n; currentAP=temp;}
		}
		if (found==0) previousAPIndex=len;
		return found;
	}
	
	public MobileNode getNode(String name)
	{
		MobileNode temp = null;
		int len = mobileNodeList.size();
		for (int n =0; n < len; n++)
		{
			temp = mobileNodeList.get(n);
			if (temp.getName().equals(name)) { break;}
		}
		return temp;
	}
	
	
	//gets the first random position of a building if seen for first time in self map
	private Vector3f getBuildingStartLoc(String building, AccessPoint previousAP, int weight)
	{
		Vector3f loc = new Vector3f(0,0,0);
		
		if (previousAP==null || weight > upperBound)
		{
			System.out.println("RANDOM LOCATION SET");
			//set a random position as first ap or time gap too long
			double randx = Math.random() * 100;
			double randy = Math.random() * 100;
			loc = loc.add((float)randx,0,(float)randy);
			//CONVERT TO CART PLANE
			loc = loc.add(-50,0,-50);
			loc.x=loc.x*-1;
			proxied=false;
		}
		else
		{
			//got previous AP 
			if (weight <= upperBound)
			{
				System.out.println("PROXIMITY LOCATION SET TO:"+previousAP.nodeName);
				//position near previous ap using weight
				//int tweight = Math.round(weight / ( upperBound / 10) );
				int tweight = Math.round(weight / 2 );
				Vector3f preloc = previousAP.getLocation(previousAP.getNumberOfNodes()-1);
				System.out.println("Previous AP Loc="+preloc.x+","+preloc.z+" weight="+tweight);
				double xrange = (preloc.x+ (Math.cos(theta) * Math.random()*tweight));
				double yrange = (preloc.z+ (Math.cos(theta) * Math.random()*tweight));
				System.out.println("x="+xrange+" y="+yrange);
				loc = loc.add((float)xrange,0,(float)yrange);
				proxied=true;
			}
			else
			{
				System.out.println("THIS SHOULD NEVER HAPPEN");
			}
		}
		return loc;
	}
	
	public Vector3f adjustAP(int weight)
	{
		Vector3f loc = new Vector3f(0,0,0);
		System.out.println("PROXIMITY LOCATION CHNAGE:"+previousAP.getName()+" moved near "+currentAP.getName());
		//position preap near cur ap using weight
		int tweight = Math.round(weight / 2 );
		Vector3f preloc = currentAP.getLocation(currentAP.getNumberOfNodes()-1);
		Vector3f previousloc = previousAP.getLocation(previousAP.getNumberOfNodes()-1);
		System.out.println(currentAP.getName()+" x="+preloc.x+" u="+preloc.z+" weight="+tweight);
		System.out.println(previousAP.getName()+" x="+previousloc.x+" u="+previousloc.z+" weight="+tweight);
		double xrange = (preloc.x+ (Math.cos(theta) * Math.random()*tweight));
		double yrange = (preloc.z+ (Math.cos(theta) * Math.random()*tweight));
		System.out.println("new x="+xrange+" new y="+yrange);
		loc = loc.add((float)xrange,0,(float)yrange);
		return loc;
	}
	
	private Vector3f getBuildingLoc(String building)
	{
		Vector3f loc = new Vector3f(0,0,0);
		AccessPoint temp;
		int found = 0;
		int len = accessPointList.size();
		for (int n =0; n < len; n++)
		{
			temp = accessPointList.get(n);
			if (temp.getName().equals(building)) { found=1; loc = temp.getLocation(temp.getNumberOfNodes()-1);}
		}
		return loc;
	}
	
	private Vector3f getBuildingLocStatic(String building)
	{
		Vector3f loc = new Vector3f(0,0,0);
		if (building.equals("lis")) {loc = loc.add(75,0,42); }
		if (building.equals("eng")) {loc = loc.add(59,0,35); }
		if (building.equals("wal")) {loc = loc.add(24,0,37); }
		if (building.equals("ils")) {loc = loc.add(9,0,40); }
		if (building.equals("glyn")) {loc = loc.add(18,0,51); }
		if (building.equals("viv")) {loc = loc.add(18,0,65); }
		if (building.equals("ful")) {loc = loc.add(42,0,58); }
		if (building.equals("grv")) {loc = loc.add(28,0,59); }
		if (building.equals("law")) {loc = loc.add(18,0,86); }
		if (building.equals("marg")) {loc = loc.add(8,0,27); }
		if (building.equals("james")) {loc = loc.add(83,0,53); }
		if (building.equals("khard")) {loc = loc.add(75,0,59); }
		if (building.equals("digi")) {loc = loc.add(55,0,58); }
		if (building.equals("tali")) {loc = loc.add(65,0,58); }
		if (building.equals("kil")) {loc = loc.add(39,0,78); }
		if (building.equals("pre")) {loc = loc.add(32,0,89); }
		if (building.equals("cfn")) {loc = loc.add(25,0,95); }
		if (building.equals("oxw")) {loc = loc.add(32,0,82); }
		if (building.equals("lang")) {loc = loc.add(38,0,85); }
		if (building.equals("cas")) {loc = loc.add(36,0,92); }
		if (building.equals("acu")) {loc = loc.add(92,0,48); }
		if (building.equals("hald")) {loc = loc.add(22,0,76); }
		if (building.equals("hor")) {loc = loc.add(55,0,74); }
		if (building.equals("pen")) {loc = loc.add(47,0,74); }
		//CONVERT TO CART PLANE
		loc = loc.add(-50,0,-50);
		loc.x=loc.x*-1;
		return loc;
		 
	}
	
	private int getBuildingSize(String building)
	{
		int rad = 0;
		if (building.equals("lis")) {rad=10; }
		if (building.equals("eng")) {rad=12; }
		if (building.equals("wal")) {rad=14; }
		if (building.equals("ils")) {rad=6; }
		if (building.equals("glyn")) {rad=8; }
		if (building.equals("viv")) {rad=7; }
		if (building.equals("ful")) {rad=10; }
		if (building.equals("grv")) {rad=8; }
		if (building.equals("law")) {rad=11; }
		if (building.equals("marg")) {rad=7; }
		if (building.equals("james")) {rad=11; }
		if (building.equals("khard")) {rad=11; }
		if (building.equals("digi")) {rad=10; }
		if (building.equals("tali")) {rad=12; }
		if (building.equals("kil")) {rad=8; }
		if (building.equals("pre")) {rad=8; }
		if (building.equals("cfn")) {rad=8; }
		if (building.equals("oxw")) {rad=8; }
		if (building.equals("lang")) {rad=8; }
		if (building.equals("cas")) {rad=8; }
		if (building.equals("kei")) {rad=9; }
		if (building.equals("acu")) {rad=10; }
		if (building.equals("hald")) {rad=10; }
		if (building.equals("hor")) {rad=8; }
		if (building.equals("pen")) {rad=7; }		
		return rad;
		 
	}
	
	private Vector3f getAPLoc(String ap, String floor, String position)
	{
		Vector3f loc = new Vector3f(0,0,0);
		int floorx = Integer.parseInt(floor);
		loc.y = floorx *10;
		if (position.equals("s")) { loc.x=10; loc.z=12;	}
		if (position.equals("c")) { loc.x=50; loc.z=12;	}
		if (position.equals("k")) { loc.x=90; loc.z=12;	}
		//CONVERT TO CART PLANE
		loc = loc.add(-50,0,-12.5f);
		loc.x=loc.x*-1;
		return loc;
		 
	}
	
	public ArrayList<MobileNode> getNodeList()
	{
		return mobileNodeList;
	}

	public ArrayList<AccessPoint> getAPList()
	{
		return accessPointList;
	}
	
	public void dumpData()
	{
		AccessPoint temp;
		int len = accessPointList.size();
		int numneigh = 0;
		for (int n =0; n < len; n++)
		{
			temp = accessPointList.get(n);
			System.out.println("*********AccessPoint:"+temp.getName());
			numneigh = temp.getNumberNeighbours();
			System.out.println("*********Number of Neighbours="+numneigh);
			for (int x =0; x < numneigh; x++)
			{
				Neighbour tneighbour = temp.getNeighbour(x);
				if (tneighbour!=null)
				System.out.println("***********Neighbour:"+tneighbour.getNeighbourName()+" with BMU="+tneighbour.getNeighbourBMU());
				else System.out.println("***********Neighbour:NULL???");
			}
		}

	}

}
